import React, { useState } from 'react';
import { ConfigProvider, Form, Input, Button } from 'antd';
import logo from '@/assets/imgs/mayImg1.png';
// import partsManufacturing from '@/assets/imgs/partsManufacturing@2x.png';
import loginBg from '@/assets/imgs/login@2x.png';
import biglogo from '@/assets/imgs/biglogo@2x.png';
import LoginForm from './loginForm'
import RegisterForm from './RegisterForm';

import './style.less';

const LoginPage = () => {

  const [isLogin,setIsLogin] = useState(true);
  const [defaultUsername, setDefaultUsername] = useState('');

  return (
    <div className="loginContainer">
      <div className="backgroundContainer">
        <img src={biglogo} alt="logo" className="logoStyle" />
        <div className="contentContainer">
          {/* 左侧图片 */}
          <div className="leftSection">
            <div className="imageWrapper">
              <img src={loginBg} alt="背景图" className="loginImage" />
            </div>
          </div>
          {/* 右侧表单 */}
          <div className="rightSection">
            <div className="formContainer">
                <div className="logoContainer">
                  <img src={logo} alt="Logo" className="logoImg" />
                  <strong className="loginTxt">蚂蚁工场产教融合创新平台</strong>
                </div>
                {isLogin ? (
                <>
                  <LoginForm defaultUsername={defaultUsername}/>
                  <div className="formBottom">
                    <span className="text-tip">没有账号?现在</span>
                    <span className="topRegister" onClick={() => setIsLogin(false)}>
                      注册
                    </span>
                  </div>
                </>
              ) : (
                <>
                  <RegisterForm onRegisterSuccess={(username) => {
                    setIsLogin(true);         
                    setDefaultUsername(username); 
                  }} />
                  <div className="formBottom">
                    <span className="text-tip">已有账号?现在</span>
                    <span className="topRegister" onClick={() => setIsLogin(true)}>
                     登录
                    </span>
                  </div>
                </>
              )}
            </div>
          </div>
        </div>
      </div>
    </div>
  );
};

export default LoginPage;